package log.aop;

import log.constant.LogConstants;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;

/**
 * @author
 */
@Slf4j
@Aspect
@Order(3)
@Component
public class ConsoleServiceAspect extends BaseAspect {

    /**
     * 针对service的日志
     */
    @Pointcut("@within(org.springframework.stereotype.Service)")
    public void pointCut() {}

    /**
     */
    @Around(value = "pointCut()")
    public Object around(ProceedingJoinPoint point) throws Throwable {
        super.outputConsoleLogs(point, LogConstants.STOREY_SERVICE, LogConstants.IN, null);
        Object result = point.proceed();
        super.outputConsoleLogs(point, LogConstants.STOREY_SERVICE, LogConstants.OUT, null);
        return result;
    }

}
